<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- <link rel="stylesheet" type="text/css" href="http://unpkg.com/view-design/dist/styles/iview.css"> -->
    <script type="text/javascript" src="./vue.js"></script>
    <title>组件详解</title>
</head>
<body>
<div id="app">
    <my-list :books="books">
        <template slot="book" scope="props">
            <li>{{props.book.id}} - {{props.book}}</li>
        </template>
    </my-list>
</div>
<script>
    Vue.component('my-list',{
        props:{
            books:{
                type:Array,
                default:function(){
                    return [];
                }
            }
        },
        template:'<ul> <slot name="book" v-for="book in books" :book="book"></slot>' +
            '</ul>'
    });

    var app = new Vue({
        el:'#app',
        data:{
            books:[
                {name:'a',id:1},
                {name:'b',id:2},
                {name:'c',id:3}
            ]
        }
    });
</script>
</body>
</html>